#include <iostream>
#include "common.h"
#include "matrix_mul.h"

using namespace common;


int main() {
  // 1、初始化。根据自己的实际device填写deviceId
  int32_t deviceId = 0;
  aclrtStream stream;
  auto ret = Init(deviceId, &stream);
  CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("Init acl failed. ERROR: %d\n", ret); return ret);

  // 2、构造输入与输出，需要根据API的接口自定义构造
  int m = 3;
  int k = 2;
  int n = 3;
  float x[] = {7.0f,1.0f,5.0f,4.0f,8.0f,2.0f};
  float y[] = {1.0f,4.0f,2.0f,5.0f,3.0f,6.0f};
  float* r = new float[m*n];

  // 3、调用方法计算矩阵相乘
  ret = matrix::Mul(&stream, x, y, r, m, k, n);
  CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("MatMul calculation failed. ERROR: %d\n", ret); return ret);

  // 4、输出结果
  for (int64_t i = 0; i < m * n; i++) {
    LOG_PRINT("result[%ld] is: %f\n", i, r[i]);
  }

  // 5、释放资源
  aclrtDestroyStream(stream);
  aclrtResetDevice(deviceId);
  aclFinalize();
  return 0;
}